var express = require("express");
var router = express.Router();

/* GET users listing. */
router.get("/", function (req, res, next) {
  res.send("respond with a resource");
});

router.post("/login", function (req, res, next) {
  console.log("登录请求参数：", req.body);
  const { username, pwd } = req.body;

  if (username === pwd) {
    res.json({
      code: "200",
      msg: "登陆成功",
      data: {
        userId: Date.now(),
        username,
        token: "cbkasbck",
      },
    });
  } else {
    res.json({
      code: "1001",
      msg: "账号或者密码错误",
    });
  }
});

module.exports = router;
